import {
    cofirmAction
} from './actionTypes';

export const mutations = {
    updateHomeData(state, res) {
        state[cofirmAction.UPDATE_HOME_DATA] = res
    },
    updateLeftMenu(state, res) {
        let kk = JSON.parse(JSON.stringify(res.provinceDtoList)),
            temp = [];
        for (let i = 0; i < kk.length; i++) {
            temp.push(kk[i])
            for (let j = 0; j < kk.length; j++) {
                if (temp[i].provinceName === kk[j].provinceName && temp[i].tailingAreaId !== kk[j].tailingAreaId) {
                    for (let b = 0; b < kk[j].cityDtoList.length; b++) {
                        temp[i].cityDtoList.push(kk[j].cityDtoList[b])
                    }
                    console.log(temp[i].cityDtoList);
                }
            }
            for (let j = 0; j < temp[i].cityDtoList.length; j++) {
                temp[i].cityDtoList[j]['label'] = temp[i].cityDtoList[j].cityName;
                console.log(temp[i].cityDtoList);
                for (let c = 0; c < temp[i].cityDtoList[j].tailingPondList.length; c++) {
                    temp[i].cityDtoList[j].tailingPondList[c]['label'] = temp[i].cityDtoList[j].tailingPondList[c].tailingName
                }
                temp[i].cityDtoList[j]['children'] = temp[i].cityDtoList[j].tailingPondList
            }
            temp[i]['label'] = temp[i].provinceName
            temp[i]['children'] = temp[i].cityDtoList
        }
        state[cofirmAction.UPDATE_LEFTMENU] = temp
        
    },
    updateMonitorTypeList(state, res) {
        state[cofirmAction.UPDATE_MONTORTYPE] = res
    },
    updateMonitorList(state, res) {
        state[cofirmAction.UPDATE_MONITORLIST] = res
        console.log(res);
    }
}